﻿using Inovout.Cloud.Applications.Models;
using Inovout.Cloud.Models;
using Inovout.Repositories;
using NHibernate.Criterion;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Inovout.Cloud.Repositories
{
    public class ProjectRepository : DataObjectRepository<Project>
    {
        public Project FindByApplication(Application application)
        {
            var list = base.OpenSession().CreateCriteria<Project>()
                .CreateCriteria("Applications", "application")
                .Add(Restrictions.Eq("application.Id", application.Id))
                .List<Project>();
            return Single(list);
        }
    }
}
